<template>
  <div class="ma-content-block lg:flex justify-between p-4">
    <!-- CRUD 组件 -->
    <ma-crud :options="options" :columns="columns" ref="crudRef">
      <template #sum_unit_money="{ record }">
        {{ tool.toFixed(record.sum_unit_money, 2, 10000) }}

      </template>
      <template #sum_money="{ record }">
        {{ tool.toFixed(record.sum_money, 2, 10000) }}
      </template>

      <template #sum_expend="{ record }">
        {{ tool.toFixed(record.sum_expend, 2, 10000) }}
      </template>

      <template #mao_li="{ record }">
        {{ tool.toFixed(record.mao_li, 2, 10000) }}
      </template>

    </ma-crud>

  </div>
</template>
<script setup>
import {ref, reactive} from 'vue'
import boxInfo from '@/api/box/boxInfo'
import {Message, Modal} from '@arco-design/web-vue'
import tool from '@/utils/tool'
import * as common from '@/utils/common'




const crudRef = ref()



const numberOperation = (newValue, id, numberName) => {
  boxInfo.numberOperation({id, numberName, numberValue: newValue}).then(res => {
    res.success && Message.success(res.message)
  }).catch(e => {
    console.log(e)
  })
}

const switchStatus = (statusValue, id, statusName) => {
  boxInfo.changeStatus({id, statusName, statusValue}).then(res => {
    res.success && Message.success(res.message)
  }).catch(e => {
    console.log(e)
  })
}
const handleSearch = (value) => {
  console.log(value)
}

const options = reactive({
  id: 'us_box_info',

  pk: 'id',
  operationColumn: false,
  operationColumnWidth: 220,
  formOption: {
    viewType: 'modal',
    width: 600
  },
  api: boxInfo.getStatsBox,
  recycleApi: boxInfo.getRecycleList
})

const columns = reactive([
  {
    title: "盒子名称",
    dataIndex: "name",
    width: 160,
    formType: "input",
    search: true,
    commonRules: {
      required: true,
      message: "请输入盒子名称"
    }
  },
  {
    title: "单价",
    dataIndex: "sum_unit_money",
    width: 180,

  },
  {
    title: "收入",
    dataIndex: "sum_money",
    formType: "input",

  },
  {
    title: "支出",
    dataIndex: "sum_expend",
    formType: "input",

  },
  {
    title: "参与人数",
    dataIndex: "count_row_user",
    formType: "select",

  },
  {
    title: "次数",
    dataIndex: "count_row",
  },
  {
    title: "人均次数",
    dataIndex: "count_average",
    formType: "input"
  },
  {
    title: "盈利人数",
    dataIndex: "row_count_yinli",
    formType: "input"
  },
  {
    title: "毛利",
    dataIndex: "mao_li",
    formType: "input"
  },
  {
    title: "毛利率",
    dataIndex: "mao_li_li",
    formType: "input"
  },
  {
    title: "时间",
    dataIndex: "create_time_stat",
    formType: "range",
    search: true,
    addDisplay: false,
    editDisplay: false,
    showTime: true,
    hide:true
  },

])
</script>
<script> export default {name: 'box:info'} </script>